// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
   ssr: true, // 确保启用SSR
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true }, 
  postcss: {
    plugins: {
      tailwindcss: {},
      autoprefixer: {},
    },
  },
 css: ['~/assets/css/main.css','element-plus/dist/index.css','~/assets/css/theme.css'],
  vite: {
     css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "~/assets/styles/element.scss" as *;`,
          javascriptEnabled: true
        }
      }
    }
  },
    modules: ['@element-plus/nuxt','@nuxtjs/tailwindcss','@nuxtjs/seo'],
   elementPlus: {
    icon: 'ElIcon',  // 启用图标自动导入
    importStyle: false
  },
   plugins: [
    '~/plugins/pinia.ts', // 确保路径正确
    '~/plugins/axios.ts' //引入axios确保路径正确
  ],
   seo: {
    // 全局 SEO 配置
    title: '默认标题',
    description: '默认描述',
    keywords: '默认关键词',
    // 其他全局配置...
  },
  // 添加百度统计代码
head: {
    script: [
      {
        innerHTML: `
          var _hmt = _hmt || [];
          (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?YOUR_BAIDU_TRACKING_ID";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
          })();
        `,
        charset: 'utf-8',
        defer: true,
        body: true
      }
    ]
  },
 nitro: {
    preset: 'static',
    static: {
      // 允许预渲染跳过特定路由
      skipFallback: ['/api/todos']
    },
     externals: {
      exclude: ['unstable-module']
    }
  },
  generate: {
    // 显式指定生成路由
    routes: ['/about', '/todos']
  }
 
})